using System;
using PostSharp.Extensibility;

namespace CriticalSystems.Instrumentation
{
    /// <summary>
    /// Traces entry and exit from a method.
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module |
                    AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method
                    | AttributeTargets.Constructor,
        AllowMultiple = true, Inherited = false)]
    [MulticastAttributeUsage(MulticastTargets.Method | MulticastTargets.Constructor, AllowMultiple = true)]
    public sealed class TracingAttribute : MulticastAttribute, IRequirePostSharp
    {
        #region IRequirePostSharp Members
        /// <summary>
        /// Returns the requirements of the current attribute in the post-compilation process.
        /// </summary>
        /// <returns>A <see cref="PostSharpRequirements"/> object meaning that the 
        /// task named <b>Tracing</b> is required.</returns>
        PostSharpRequirements IRequirePostSharp.GetPostSharpRequirements()
        {
            PostSharpRequirements requirements = new PostSharpRequirements();
            requirements.PlugIns.Add("CriticalSystems.Instrumentation");
            requirements.Tasks.Add("CriticalSystems.Instrumentation");
            return requirements;
        }
        #endregion
    }
}